Skip to main content
Feedback

Groovy: Accessing process properties

You can access Process Property components and dynamic process properties within your map function script. This sample Groovy custom scripting function accesses a dynamic process property that serves as a counter to track the number of “priority” orders being mapped.

  • Process Property components use getProcessProperty and setProcessProperty.

  • Dynamic process properties use getDynamicProcessProperty and setDynamicProcessProperty.

Although you can usually achieve the same result using individual Get Process Property and Set Process Property function steps, sometimes doing it within the script can be less convoluted, especially if you need to get and set multiple properties.

JavaScript example

CategoryDetails
InputspriorityFlag (Character)
Outputs<none>
Scriptload("nashorn:mozilla_compat.js");
// Import the ExecutionUtil class
importClass(com.boomi.execution.ExecutionUtil);

propName = "PRIORITY_COUNT";

// Retrieve current Process Property value
propValue = ExecutionUtil.getDynamicProcessProperty(propName);

// Convert string value to int to do math
var intValue = parseInt(propValue);

// Increment value by 1 if priorityFlag is "true"
if (priorityFlag == "true") { <br /> intValue = intValue + 1;
}

// Convert int value back to String before storing in property
propValue = intValue.toString();

// Set the new property value. The 3rd parameter indicates if the property should be persisted (true) or not (false).
ExecutionUtil.setDynamicProcessProperty(propName, propValue, false);

Groovy example

CategoryDetails
InputspriorityFlag (Character)
Outputs<none>
Scriptload("nashorn:mozilla_compat.js");
// Import the ExecutionUtil class
importClass(com.boomi.execution.ExecutionUtil);

propName = "PRIORITY_COUNT";

// Retrieve current Process Property value
propValue = ExecutionUtil.getDynamicProcessProperty(propName);

// Convert string value to int to do math
var intValue = parseInt(propValue);

// Increment value by 1 if priorityFlag is "true"
if (priorityFlag == "true") { <br /> intValue = intValue + 1;
}

// Convert int value back to String before storing in property
propValue = intValue.toString();

// Set the new property value. The 3rd parameter indicates if the property should be persisted (true) or not (false).
ExecutionUtil.setDynamicProcessProperty(propName, propValue, false);